<?php
$fechade = $_REQUEST['fecini'];
$fechaa = $_REQUEST['fecfin'];
//$nomnotaria = "Nombre de la Notaria";
$nomnotaria = " ";
//$fechade = '01/01/2013';
//$fechaa = '31/01/2013';
?>

            <style type="text/css">
			#logo_emp{
				float:left;
				padding:0px;
				margin:0px;
				margin-top:10px;
				margin-left:10px;
				}
			#fec_actual{
				float:right;
				padding:0px;
				margin:0px;
				margin-top:10px;
				margin-right:10px;
				}	
			</style>

<?php 
include('conexion.php');

//$fechade=$_REQUEST['fecini'];
$fechade = $_REQUEST['fecini'];

$tiempo = explode ("/", $fechade);
$desde = $tiempo[2] . "-" . $tiempo[1] . "-" . $tiempo[0];

//$fechaa = $_REQUEST['fecfin'];
$fechaa = $_REQUEST['fecfin'];

$tiempo2 = explode ("/", $fechaa);
$hasta = $tiempo2[2] . "-" . $tiempo2[1] . "-" . $tiempo2[0];

$consulta = mysql_query("SELECT num_carta, DATE_FORMAT(STR_TO_DATE(fec_ingreso,'%d/%m/%Y'),'%d/%m/%Y'), fec_entrega, nom_remitente, nom_destinatario,zona_destinatario FROM ingreso_cartas WHERE STR_TO_DATE(fec_ingreso,'%d/%m/%Y') BETWEEN STR_TO_DATE('$fechade','%d/%m/%Y') AND STR_TO_DATE('$fechaa','%d/%m/%Y') ORDER BY num_carta asc", $conn) or die(mysql_error());

while($row = mysql_fetch_array($consulta)){

$numcarta = $row[0];
$numcarta2 = substr($numcarta,5,6).'-'.substr($numcarta,0,4);

echo"<table width='834' align=center' border='1' cellpadding='0' cellspacing='0' bordercolor='#E5E5E5'>
  <tr>
    <td width='70'  height='19' valign='top'><span class='Estilo12'>".$numcarta2."</span></td>
    <td width='86'  valign='top'><span class='Estilo12'>".$row[1]."</span></td>
    <td width='86'  valign='top'><span class='Estilo12'>".$row[2]."</span></td>
    <td width='93'  valign='top'><span class='Estilo12'>";
	
	$consulta2 = mysql_query("SELECT ubigeo.nomdis FROM ubigeo WHERE ubigeo.coddis='".$row[5]."' ", $conn) or die(mysql_error());
	while($row2 = mysql_fetch_array($consulta2)){
		echo $row2[0];
	}
	 echo"</span></td>
    <td width='171' valign='top'><span class='Estilo12'>";
	$textormat=str_replace("?","'",$row[3]);
    $textoampermat=str_replace("*","&",$textormat);
	echo strtoupper($textoampermat);
	echo"</span></td>
    <td width='275' valign='top'><span class='Estilo12'>";
	$textormat4=str_replace("?","'",$row[4]);
    $textoampermat4=str_replace("*","&",$textormat4);
	echo strtoupper($textoampermat4);
	echo"</span></td>
  </tr>
</table>";
}
?>
